import java.util.Stack;

public class MyQueue2 {
    private Stack<Integer> s1;
    private Stack<Integer> s2;

    public MyQueue2 () {
        s1 = new Stack<Integer>();
        s2 = new Stack<Integer>();
    }

    public void push(int val) {
        s1.push(val);
    }

    //弹出
    public int pop() {
        if (empty()) {
            return -1;
        }

        if (s2.empty()) {
            while(!s1.empty()) {
                s2.push(s1.pop());
            }
        }

        return s2.pop();
    }

    public int peek() {
        if (empty()){
            return -1;
        }
        if (s2.empty()) {
            while(!s1.empty()) {
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    public boolean empty(){
        return s1.empty() && s2.empty();
    }

}
